import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const store=new Vuex.Store({
    state:{
        count:0
    },
    mutations:{
        INCRMENT_COUNT(state,payload){
            state.count=state.count+payload
        }
    },
    actions:{
        incrementAsync(cxt,payload){
            setTimeout(() => {
                cxt.commit('INCRMENT_COUNT',payload)
            }, 2000);
        }
    },
    getters:{
        doubleCount(state){
            return 2*state.count
        }
    }
})
export default store